﻿Imports EyeOpen.IO
Imports System.IO

Namespace EyeOpen.SearchFile.Windows

	Partial Public Class MainForm
		Inherits Form
		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub SearchLinkLabelLinkClicked(ByVal sender As Object, ByVal e As LinkLabelLinkClickedEventArgs) Handles searchLinkLabel.LinkClicked
			Dim directoryInfo = New DirectoryInfo("c:\temp")

			CType(New AsyncWorker(), AsyncWorker).RunWorkerAsync(Of String)(fileNameTextBox.Text, Function(p)
																									  Dim fileName = p
																									  Dim fileInfo = directoryInfo.Search(fileName, New TextBoxLogger(searchingTextBox))
																									  If fileInfo Is Nothing Then
																										  MessageBox.Show("File not found.")
																									  Else
																										  MessageBox.Show("File path: " & fileInfo.FullName)
																									  End If
																								  End Function)
		End Sub
	End Class
End Namespace
